package com.future.direction.ui.activity;

import android.content.Intent;

import com.future.direction.R;
import com.future.direction.common.util.SharePreferencesUtils;
import com.future.direction.di.component.AppComponent;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;

/**
 * Created by zhangpeng on 2018/1/2.
 */

public class SplashActivity extends BaseActivity {
    @Override
    public int setLayout() {
        return R.layout.activity_splash;
    }

    @Override
    public boolean init() {

        Observable.timer(1, TimeUnit.SECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        jump();
                    }
                });

        return true;

    }

    @Override
    public void getExtras() {

    }

    @Override
    public void setListener() {

    }

    private void jump() {

        if (SharePreferencesUtils.isFirst()) {
            Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
            intent.putExtra("flag","0");
            startActivity(intent);
        } else {
            //导航结束后控制跳转标记
            Intent intent = new Intent(SplashActivity.this, GuideActivity.class);
            startActivity(intent);
        }
        finish();
    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

}
